package server.jsons;

import com.google.gson.annotations.Expose;

public class User extends Message{
	
	@Expose private String surname;
	@Expose private String firstname;
	@Expose private int points;
	@Expose protected String email;
	@Expose protected String password;
	
	public User(){
		super();
		userId = "-1";
		surname = "";
		firstname = "";
		points  = -1;
		this.email = "";
		this.password = "";
	}

	public User(String surname, String firstname, String email, String pwd){
		this.password = pwd;
		this.surname = surname;
		this.firstname = firstname;
		this.email = email;
	}


	public String getFirstname() {
		return firstname;
	}

	

	public int getPoints() {
		return points;
	}

	public void setPoints(int points) {
		this.points = points;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}


	public String getSurname() {
		return surname;
	}

	public void setSurname(String name) {
		this.surname = name;
	}
	
	@Override
	public int hashCode(){
		return this.email.hashCode();
	}
	
	
	/**
	 * Two Users are identical if their password hash and their email address are the same
	 */
	@Override
	public boolean equals(Object obj){
		if(obj == null){
			return false;
		}
		if(obj == this){
			return true;
		}
		if(!(obj instanceof User)){
			return false;
		}
		
		User u = (User) obj;
		if(u.email.equals(this.email)
				&& u.password.equals(this.password)){
			return true;
		}else{
			return false;
		}
	}
	
	
	public void setUserEmail(String email){
		this.email = email;
	}
	
	public String getUserEmail(){
		return this.email;
	}
	
	public String getUserPwd() {
		return password;
	}



	public void setUserPwd(String userPwd) {
		this.password = userPwd;
	}

	public void generateSessionID() {
		
		this.sessionId = String.valueOf(this.hashCode());
		return;
	}


}
